var arrs = [1, 2, [3, [4, 5], 6], 7, [8], 9];
var objs = {};

function recursionArray(arrs, obj) {
    for (let i = 0; i < arrs.length; i++) {
        const children = arrs[i];
        if (Array.isArray(children)) {
            obj["children"][i] = {};
            recursionArray(children, obj["children"][i])
        } else {
            if (obj["children"] && Array.isArray(obj["children"])) {
                obj["children"].push({
                    value: children
                })
            } else {
                obj["children"] = [{
                    value: children
                }];
            }

        }
    }
}

recursionArray(arrs, objs);
console.log(JSON.stringify(objs));

function convert(arr) {
    var result = [];
    for (let i = 0; i < arr.length; i++) {
        const children = arr[i];
        if (Array.isArray(children)) {
            result.push({
                children: convert(children)
            });
        } else {
            result.push({
                value: children
            });
        }
    }
    return result;
}

function convert2(item) {
    if (Array.isArray(item)) {
        return {
            children: item.map(_item => convert2(_item))
        }
    } else {
        return {
            value: item
        }
    }
}
console.log(JSON.stringify(convert2(arrs)));